/*
RippleTests.loadAndTestSl
RippleTests.testSynth
RippleTests.testSynthFromPreset

*/

RippleTests{

	classvar presetPath;
	
	*init{
		presetPath = "sounds/1. presets scene work 2/digi peepers test";
	}

	*loadSl{
		//presetPath = "sounds/1. presets scene work 2/digi peepers test";
		presetPath = "sounds/percussion - clattery/cool flex loop";
		^PlayerFactory.createSlFromPath(presetPath)
	}
	
	*loadAndTestSl{
		var sl, onBoot;
		sl = RippleTests.loadSl;
		
		sl.launchSynth(1);
			
	
	}
	
	*getPresetObj{
		^Object.readTextArchive(presetPath);
	}
	
	*printPresetObj{
		var p;
		this.getPresetObj.keysValuesDo{|key, val|
	
			key.asString.catArgs("->", val).postln;
	
		};
	}
	

	*testSynthFromPreset{
		var onBoot;
		
		
		onBoot = {
		
			var bufNum;
			
			RippleSynths.load;
			 
			"onBoot".postln;
		
			bufNum = BufferDuplicationPreventer.loadSoundToBuffer("sounds/field recordings/balls in funnel.aif");
			
			
			//bufNum = BufferDuplicationPreventer.loadSoundToBuffer("sounds/bass/BAMO045.WAV");
			
			
			Synth(\rippleSampler, RTest.testControls);
			
	
		
		};	
		
		Server.default.boot;
		Server.default.doWhenBooted(onBoot);	
	}


	*testSynth{ // might need to load synths and start server before calling method
		var onBoot;
		
		
		onBoot = {
		
			var bufNum;
			
			RippleSynths.load;
			 
			"onBoot".postln;
		
			bufNum = BufferDuplicationPreventer.loadSoundToBuffer("sounds/field recordings/balls in funnel.aif");
			
			
			//bufNum = BufferDuplicationPreventer.loadSoundToBuffer("sounds/bass/BAMO045.WAV");
			
			
			Synth(\rippleSampler, [
				\decay, 1,
				\len, 1,
				\startPos, 1,
				\loopLength, 1,
				\bufnum, bufNum,
				\attack, 1,
				\volume, 1,
				\volume2, 1,
				\tremeloFreq, 0,
				\tremeloDepth, 0,
				\tremeloRand, 0,
				\pan, 0,
				\pitch, 1,
				\pitchUp,0,
				\pitchDown, 0				
				]
				
			);
			
	
		
		};	
		
		Server.default.boot;
		Server.default.doWhenBooted(onBoot);	
		
	}
	
	*testControls{
		var preset,controls, factory, controlsList;
		
		presetPath = "sounds/1. presets scene work 2/digi peepers test";
		
		preset = PresetUtils.getPreset(presetPath);
		
		preset.postln;
		
		factory = ControlsFactory.new(preset);
		
		/*
		
		controlsList = factory.makeControlsList; 
		
		controlsList.keysValuesDo{|key, val|
			key.postln;
			val.postln;
		};
		
		*/
		
		
		controls = factory.makeControls;
		
		"getAsArgsArray should return an array of 20 or so".postln;
		
		"getAsArgsArray returns:".postln;
		
		controls.getAsArgsArray.postln;
		
		CollectionUtils.printCollection(controlsList);
		
		^controls.getAsArgsArray;
		
	}



















	
}

RTest : RippleTests{
	
}